package com.roc.template.mysql.mapper;

import com.roc.template.mysql.entity.Order;
import com.roc.template.mysql.vo.OrderVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @ClassName OrderMapper
 * @Description: TODO
 * @Author Administrator
 * @Date 2020/7/20 15 38
 * @Version V1.0
 **/
@Mapper
public interface OrderMapper {


    @Delete("delete  from template.`order`  where id=#{id}")
    void delete(@Param("id")String id);

    @Select({"<script>",
            "select * from  template.`order` where 1=1 ",
            "<if test='orderVo.name != null and orderVo.name != \"\"' >",
            "name like '%${orderVo.name}%'",
            "</if>",
            "<if test='orderVo.phone != null and orderVo.phone != \"\"' >",
            "and  status=#{orderVo.phone}",
            "</if>",
            "order by name desc",
            "</script>"
    })
    List<Order> pageQuery(@Param("orderVo")OrderVo orderVo);

    //新增字典数据
    @Insert("insert into template.`order`(name,phone)" +
            "values(#{order.name},#{order.phone})")
    void insert(@Param("order")Order order);


    @Select( "update template.`order` set name=#{order.name} , phone=#{order.phone}  where id=#{order.id} ")
    void update(@Param("order")Order order);
}
